package com.leyou.common.exception.controller;

import com.leyou.common.exception.domain.LyException;
import com.leyou.common.exception.domain.LyExceptionResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class LyExceptionControllerAdvice {

    /**
     * 拦截LyException
     */
    @ExceptionHandler(LyException.class)
    public ResponseEntity<LyExceptionResult> handlerLyException(LyException e){
        return ResponseEntity.status(e.getStatus()).body(new LyExceptionResult(e));
    }



}
